//
//  ST_ExampleTraitCellModel.swift
//  btvideo
//
//  Created by Jason on 2021/9/26.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//

import UIKit
import SwifterSwift
import HandyJSON

class ST_ExampleTraitCellModel: NSObject ,HandyJSON{
    
    static let maxTextWidth = (ScreenWidth - 15 - 20)/2.0 - 13 - 5
    
    var content = ""
    var width = 0.0
    var height = 0.0
    var age = 18
    var feature_name = ""
    
    var city = ""
    
    
//
    var display_text = ""
    
    var imgDisplayHeight = 0.cgFloat
    
    var contentWidth = 80.cgFloat
    
    
    var cellHeight = 10.cgFloat
    
    required override init() {
        super.init()
    }
    
    
    func figure_out_param(city:String)  {
        
        self.city = city
        
        display_text = age.string + "岁" + " " + city
        
        let w = self.width < 1 ? 1 : self.width
        
        self.imgDisplayHeight = ST_PinterestHomeCellImageWidth/w.cgFloat*self.height.cgFloat
        
        let fW =  feature_name.width(withConstrainedHeight: 100, font: UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.medium))
        
        contentWidth = display_text.width(withConstrainedHeight: 100, font: UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.medium))
         
        if ST_ExampleTraitCell.locPecGap + fW + contentWidth > ST_ExampleTraitCellModel.maxTextWidth{
            
            contentWidth = ST_ExampleTraitCellModel.maxTextWidth - ST_ExampleTraitCell.locPecGap - fW
            
        }
        
        
        cellHeight = self.imgDisplayHeight + 10 + 14
        
    }
}




